﻿
using Module.QLGiamGia;
using Module.QLHangHoa;
using Module.QLHoaDon;
using Module.QLKhachHang;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QLBH
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
            SqlConnection con = new SqlConnection
                (@"Data Source=.\SQLEXPRESS;Initial Catalog=QLBanHang;Integrated Security=True");
            SqlCommand cmd = new SqlCommand("select * from KhachHang", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            frmQLHangHoa frm = new frmQLHangHoa();
            frm.MdiParent = this;
            frm.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            foreach (var item in this.Controls)
                if (item.GetType() == typeof(MdiClient))
                {
                    MdiClient client = item as MdiClient;
                    client.Controls.Clear();
                }
        }

        private void buttonsClicked(object sender, EventArgs e)
        {
        }

        private void frmMain_Load(object sender, EventArgs e)
        {

        }

        private void panelFeatureMouseHover(object sender, EventArgs e)
        {
            Panel tempPanel = sender as Panel;
            foreach (Panel item in panel1.Controls)
                if (item.Name == tempPanel.Name&&item.BackColor!=Color.DarkCyan)
                {
                    item.BackgroundImage = new Bitmap(Environment.CurrentDirectory + "\\OpacityFill.png");
                }
        }

        private void panelFeatureMouseLeave(object sender, EventArgs e)
        {
            foreach(Panel item in panel1.Controls)
            {
                item.BackgroundImage = null;
            }
        }

        private void panelFeatureClicked(object sender, EventArgs e)
        {
            Panel tempPanel = sender as Panel;
            foreach (Panel item in panel1.Controls)
                if (item.Name == tempPanel.Name)
                {
                    item.BackColor = Color.DarkCyan;
                }
                else
                    item.BackColor = Color.Transparent;

            foreach (var item in this.Controls)
                if (item.GetType() == typeof(MdiClient))
                {
                    MdiClient client = item as MdiClient;
                    client.Controls.Clear();
                }

            Panel btnPanel = sender as Panel;
            switch (btnPanel.Name)
            {
                case "pnlHangHoa":
                    Console.WriteLine(btnPanel.Name);
                    frmQLHangHoa frmHH = new frmQLHangHoa();
                    frmHH.MdiParent = this;
                    frmHH.Show();
                    break;
                case "pnlHoaDon":
                    frmQLHoaDon frmHD = new frmQLHoaDon();
                    frmHD.MdiParent = this;
                    frmHD.Show();
                    break;
                case "pnlKhachHang":
                    frmQLKhachHang frmKH = new frmQLKhachHang();
                    frmKH.MdiParent = this;
                    frmKH.Show();
                    break;
                case"pnlKhuyenMai":
                    frmQLKhuyenMai frmGG = new frmQLKhuyenMai();
                    frmGG.MdiParent=this;
                    frmGG.Show();
                    break;
            }
        }

        

        



    }
}
